﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
                    xmlns:cntrls="clr-namespace:SomethingSpacial.CustomControls" >
    <Style TargetType="cntrls:FX">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="cntrls:FX">
                    <Border >
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="VisualStateGroup">
                                <vsm:VisualState x:Name="FlipState1">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleX" To="0" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleY" To=".95" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="FrontPanel" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="BackPanel" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleX" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleY" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="FlipState2">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleX" To="0" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleY" To=".95" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="BackPanel" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="FrontPanel" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleX" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleY" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Grid x:Name="ContentPresenters" Background="Transparent" >
                            <ContentPresenter x:Name="FrontPanel" Content="{TemplateBinding Front}"  RenderTransformOrigin="0.5,0.5"  >
                                <ContentPresenter.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform x:Name="FrontScale" ScaleX="1" ScaleY="1"/>
                                    </TransformGroup>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                            <ContentPresenter x:Name="BackPanel" Content="{TemplateBinding Back}" Opacity="0" RenderTransformOrigin="0.5,0.5" >
                                <ContentPresenter.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform x:Name="BackScale" ScaleX="0" ScaleY=".95"/>
                                    </TransformGroup>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="cntrls:ContentControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="cntrls:ContentControl">
                    <Grid x:Name="MyContentPresenter" Background="Transparent" >
                        <Grid.Resources>
                            <Storyboard x:Name="SizeAnimation" Storyboard.TargetName="SizeTransform" Duration="00:00:0.5" >
                                <DoubleAnimation x:Name="ScaleXAnimation" Storyboard.TargetProperty="ScaleX" To="1" />
                                <DoubleAnimation x:Name="ScaleYAnimation" Storyboard.TargetProperty="ScaleY" To="1" />
                                <DoubleAnimation x:Name="ContentPlaneTransformAnimation" Storyboard.TargetProperty="RotationX" Storyboard.TargetName="ContentPlaneTransform" To="0" />
                                <DoubleAnimation x:Name="MyContentOpacity" Storyboard.TargetName="ContentLocation" Storyboard.TargetProperty="Opacity" To="1" />
                            </Storyboard>
                        </Grid.Resources> 
                        <Grid.Effect>
                            <DropShadowEffect Color="#FF5E6D8D" BlurRadius="2" ShadowDepth="2"/>
                        </Grid.Effect>
                        <ContentPresenter x:Name="ContentLocation" Content="{TemplateBinding DisplayContent}" RenderTransformOrigin="0.5,0.5"    >
                            <ContentPresenter.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform x:Name="SizeTransform" ScaleX="1" ScaleY="1" />
                                </TransformGroup>
                            </ContentPresenter.RenderTransform>
                            <ContentPresenter.Projection>
                                <PlaneProjection x:Name="ContentPlaneTransform" RotationX="0" />
                            </ContentPresenter.Projection>
                        </ContentPresenter>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>